
/// SET DIRECTORY TO THE FOLDER "replication files"

// YOU DO NOT NEED TO RUN THIS CODE
// This code created the variables from open ended answers.
// You must first request to Centro de Estudios Públicos coordinator the files with the open ended answer.


** use "name_dataset.dta", clear


gen e40_otros = lower(ESP_40OTRO)
gen d40carab=0
replace d40carab=1 if regexm(e40_otros,"carab")
replace d40carab=1 if regexm(e40_otros,"uniform")
replace d40carab=1 if regexm(e40_otros,"pacos")


gen e39_otros = lower(ESP_39OTRO)
gen d39carab=0
replace d39carab=1 if regexm(e39_otros,"carab")
replace d39carab=1 if regexm(e39_otros,"uniform")
replace d39carab=1 if regexm(e39_otros,"pacos")
replace d39carab=1 if regexm(e39_otros,"bineros")
replace d39carab=1 if regexm(e39_otros,"fuerzas")
replace d39carab=1 if regexm(e39_otros,"polic")
replace d39carab=1 if regexm(e39_otros,"ilitares")



egen float strata_cep = group(REGION ZONA)

* tipology

gen tipo=1 if ESP_33==1
replace tipo=2 if ESP_33==2
replace tipo=3 if ESP_33>2 & ESP_32<3
replace tipo=4 if ESP_32==5 | ESP_32==4
replace tipo=5 if ESP_32>6 |ESP_32==3


label define ltipo 1 "Strong protester" 2 "Weak protester" 3 "Supporter" ///
						4 "Opponent" 5 "Undecided"
label values tipo ltipo

* Political characterization

gen sexo=DS_P1
gen edad=DS_P2_EXACTA

gen educ = 1 if DS_P4<4
replace educ = 2 if DS_P4==4 | DS_P4==5 | DS_P4==7
replace educ = 3 if DS_P4==6 | DS_P4==8 | DS_P4==9


label define leduc 1 "Uncompleted secondary" 2 "Completed secondary" /// 
					3 "Completed tertiary"
label values educ leduc


keep UMP PONDERADOR strata_cep tipo educ sexo edad d39carab d40carab

save "cep84_resp.dta"
